<template>
	<view class="login-outer-wrapper" :style="{backgroundImage:'url('+PictureUrl+'bg-login.png)'}">
		<div class="empty2"></div>
		<image class="logo" :src="PictureUrl+'logo.png'" mode="aspectFit"></image>
		<div class="empty1"></div>
		<image class="image" :src="PictureUrl+'image-init.png'" mode="aspectFit"></image>
		<div class="text">科学分析—智能监测</div>
		<div class="empty3"></div>
	</view>
</template>

<script>
	import storage from "@/utils/storage";
	import {
		mapActions,
		mapGetters
	} from 'vuex'
	export default {
		data() {
			return {};
		},
		onLoad() {
			setTimeout(() => {
				const token = storage.getToken();
				if (token) {
					const userInfo = storage.getUserInfo();
					if (!userInfo) {
						uni.redirectTo({
							url: "/pages/moduleLogin/login/login",
						});
						return
					}
					this.ActionUserList({
						token: token,
						user: userInfo,
						utype: userInfo.utype,
						type: 'login'
					})
				} else {
					uni.switchTab({
						url: "/pages/index/index",
					});
				}
			}, 2000)
		},
		computed: {
			...mapGetters(['PictureUrl'])
		},
		methods: {
			...mapActions(['SetUserInfo', 'ActionUserList']),
			redirectTo(url) {
				uni.redirectTo({
					url,
				});
			},
		},
	};
</script>

<style lang="scss">
	.login-outer-wrapper {
		height: 100vh;
		background-size: cover;
		background-position: center;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		align-items: center;

		.logo {
			width: 300upx;
			height: 300upx;
		}

		.image {
			width: 640upx;
			height: 400upx;
		}

		.text {
			margin-top: 100upx;
			color: #009084;
			font-size: 36upx;
			text-align: center;
		}

		.empty3 {
			flex: 3;
		}

		.empty2 {
			flex: 2;
		}

		.empty1 {
			flex: 1;
		}
	}
</style>
